Add min bloom filter crate - #144
Open
aneubeck wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ab0460bc-ae55-4457-a8e0-00169d9c2692
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a four-bit split-block Bloom filter with architecture-specific acceleration and performance benchmarks.
Changes:
- Implements max insertion, min retrieval, sizing, and tests.
- Adds an AArch64 NEON fast path.
- Adds documentation and comparative Criterion benchmarks.
Show a summary per file
| File | Description |
|---|---|
README.md |
Lists the new crate. |
crates/min-bloom-filter/src/lib.rs |
Implements the filter and tests. |
crates/min-bloom-filter/README.md |
Documents usage and benchmarks. |
crates/min-bloom-filter/Cargo.toml |
Defines crate metadata and dependencies. |
crates/min-bloom-filter/benchmarks/performance.rs |
Benchmarks against sbbf-rs-safe. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Balanced
Comment on lines
+130
to
+134
| #[cfg(target_arch = "aarch64")] | ||
| #[inline] | ||
| fn insert_block(block: &mut [u32; WORDS_PER_BLOCK], hash: u32, value: u8) { | ||
| // SAFETY: NEON is mandatory on AArch64, and `block` points to eight valid u32 values. | ||
| unsafe { neon::insert(block.as_mut_ptr(), hash, value) } |
Comment on lines
+49
to
+53
| let probes = WORDS_PER_BLOCK as f64; | ||
| let bits_per_entry = -probes / (1.0 - false_positive_rate.powf(1.0 / probes)).ln(); | ||
| let total_bits = | ||
| (expected_entries as f64 * bits_per_entry * f64::from(MAX_VALUE.ilog2() + 1)).ceil() | ||
| as usize; |
Comment on lines
+26
to
+29
| | Target FPR | Memory | Insert | Retrieve | | ||
| |---|---:|---:|---:| | ||
| | 1% | 14.52 MB | 2.27 ns/entry | 1.42 ns/entry | | ||
| | 0.1% | 21.91 MB | 2.74 ns/entry | 1.58 ns/entry | |
itsibitzi
reviewed
Aug 5, 2026
Comment on lines
+31
to
+36
| For comparison, `sbbf-rs-safe` on the same hashes: | ||
|
|
||
| | Target FPR | Insert | Contains | | ||
| |---|---:|---:| | ||
| | 1% | 1.50 ns/entry | 1.24 ns/entry | | ||
| | 0.1% | 1.55 ns/entry | 1.26 ns/entry | |
Contributor
There was a problem hiding this comment.
We might want to explain that this is doing something else so the better performance isn't apples-to-apples.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ab0460bc-ae55-4457-a8e0-00169d9c2692
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
u32sbbf-rs-safeover 3 million entriesFalse-positive sizing
For block occupancy
X ~ Poisson(lambda), the false-positive probability is:Numerically solving this expression gives 13.43 nibbles/entry for 1% FPP and 25.34 nibbles/entry for 0.1% FPP. Over 10 million absent queries, observed rates were 0.9941% and 0.0991%.
Apple M4 Max benchmark results
An ordinary optimally sized Bloom filter requires 3.59 MB and 5.39 MB, respectively.
Value accuracy
For 3 million inserted values drawn from geometric distributions with ratios 0.5 and 0.2, all 10 million inserted-key queries returned the exact value; no overestimation was observed.
Run with: